<?php
/**
 * easy framework PHP
 * ITA
 * @version 0.1
 * @author Davide Zorzan
 */

// first and foremost, start our sessions
session_start();
$args = array();
$routing = array();
// setup some definitions
//error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); //0 to turn off

/**
 * altre costanti
 * */
define("DS",DIRECTORY_SEPARATOR);
define("APP_PATH", dirname( __FILE__ ) ."/" );
define('ROOT', dirname(dirname(__FILE__)));
require_once(APP_PATH.DS.'configurations'.DS.'configuration.php');
$args = (!empty($_SERVER['QUERY_STRING']) ? 
			explode('/', substr(strtolower($_SERVER['QUERY_STRING']), 4)) : array());
//pulisco argomenti passati			
if (!empty($args))
	array_walk($args, function($val,$key) use(&$args){ $args[$key]= preg_replace('/([^A-Za-z0-9_])/',"",$val);});			

if (DEBUG)
{
	include_once (APP_PATH.DS.'library-class'.DS.'FirePHPCore'.DS.'fb.php');
	fb(NAME,'Nome Applicazione avviata',FirePHP::INFO);
}

require_once (APP_PATH.DS.'configurations'.DS.'dbconfig.class.php');

/**
 * Magic autoload function
 * used to include the appropriate -controller- files when they are needed
 * @param String the name of the class
 */
function __autoload( $class_name )
{
	$filename = APP_PATH.DS.'library-class'. DS .strtolower(substr($class_name,0,-5)) . '.class.php';
	if (DEBUG > 1) fb($class_name,'Classe caricata');
	if (file_exists($filename))
		require_once($filename);
}

function e ($txt)
{
	if (!empty($txt))
		echo htmlentities($txt);
}
//class for load template and execute controller
//require_once('home.php');
// print out the frameworks name - just to check everything is working

$run_application = new Manager_CoreClass();
$run_application->setLoad($active_obj);
$run_application->run($args,$routing);

exit();
?>
